<template>
  <view class="toast-container">
    <view class="toast-content">
      <view class="toast-icon">
        <Loading v-if="loading_type === 'loading'"></Loading>
        <img v-else-if="loading_type === 'waring'" src="@/static/images/waring.png" alt="" />
        <img v-else src="@/static/images/success.png" alt="" />
      </view>
      <div class="toast-title" v-html="message"></div>
    </view>
  </view>
</template>

<script lang="ts">
import Vue from 'vue'
import { mapState } from 'vuex'
export default Vue.extend({
  computed: {
    ...mapState('user', ['loading_type', 'message'])
  }
})
</script>

<style lang="scss" scoped>
.toast-container {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: $uni-bg-color-mask;
  z-index: 1000;

  .toast-content {
    background-color: $uni-bg-color-grey;
    width: 40vw;
    height: 40vw;
    border-radius: $uni-border-radius-lg;
    transform: translateY(-10vh);
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;

    .toast-icon {
      max-width: 100rpx;
      max-height: 100rpx;
      min-height: 80rpx;
      min-width: 80rpx;

      img {
        height: 100%;
        width: 100%;
      }
    }

    .toast-title {
      font-size: 32rpx;
      color: $uni-theme-color;
      text-align: center;
      margin-top: 40rpx;
    }
  }
}
</style>
